package com.qf.controller;

import com.baomidou.mybatisplus.extension.api.R;
import com.qf.service.GoodsService;
import com.qf.service.OrderService;
import com.qf.service.UserService;
import com.qf.util.ResponseUtil;
import com.qf.vo.DayStatis;
import com.qf.vo.GoodsAllinone;
import com.qf.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * projectName: wokepase1
 *
 * @author: 强力
 * time: 2021/9/14 8:32
 * description:
 */
@RestController
@RequestMapping("/stat")
@CrossOrigin("*")
public class AdminStatController {
@Autowired
    private  UserService userService;

@Autowired
private OrderService orderService;

@Autowired
  private   GoodsService goodsService;

    @RequestMapping("/user")
    public Object userstat(){
        Map data=new HashMap();
        List<Map> rows=userService.selectUser();
        String[] columns={"day","users"};
            data.put("columns",columns);
            data.put("rows",rows);

return ResponseUtil.ok(data);
    }

    @RequestMapping("/order")
    private Object Orderstat(){
        Map data=new HashMap();
        String[] columns={"day","orders","customers","amount","pcr"};
        data.put("columns",columns);
        List<Map> rows = orderService.selectorder();

        data.put("rows",rows);


        return ResponseUtil.ok(data);
    }

    @RequestMapping("/goods")
    private Object goodsstat(){
        Map data=new HashMap();
        String[] columns={"day","orders","products","amount"};
        data.put("columns",columns);
        List<Map> rows=goodsService.selegoods();
        data.put("rows",rows);
        return ResponseUtil.ok(data);
    }
}
